<template>
  <div>
    <el-menu-item index="login">
      <router-link to="/login">登录</router-link>
    </el-menu-item>
    <el-menu-item index="reg">
      <router-link to="/reg">注册</router-link>
    </el-menu-item>
  </div>
</template>
   <el-submenu index="profile" v-else>
     <template slot="title">{{userInfo.username}}</template>
     <el-menu-item @click="$router.push('/manager')">管理后台</el-menu-item>
     <el-menu-item index="logout" @click="logout">退出登录</el-menu-item>
   </el-submenu>
</template>
<script>
import { createNamespacedHelpers } from "vuex";
let { mapState, mapActions } = createNamespacedHelpers("user");
import * as types from "../store/action-types.js";
export default {
  computed: {
    ...mapState(["hasPermission", "userInfo"])
  },
  methods: {
    ...mapActions([types.USER_LOGOUT]),
    logout() {
      //在下文中可以实现这个方法
      this[types.USER_LOGOUT]();
    }
  }
};
</script>
<style lang="scss">
.header-row {
  height: 100%;
  .logo {
    margin: 5px;
    height: 50px;
  }
  .menu,
  .logo {
    display: inline-block;
  }
  .nav-right {
    float: right;
    li {
      display: inline-block;
      text-align: center;
      line-height: 60px;
    }
    a {
      color: #fff;
    }
  }
}
</style>